package edu.wust;

public class exam21 {
    public static int fatorsum(int num){
        int sum=0,half=num>>1;
        for(int i=1;i<=half;i++){
            if(num%i==0)
                sum+=i;
        }
        return sum;
    }
    public static void main(String[] args) {
        int sum=0;
        boolean num[]=new boolean[10000];
        for(int i=1;i<10000;i++){
            num[i]=true;
        }
        for(int i=1;i<10000;i++)
        {
            if(num[i]) {
                int a = i, b = fatorsum(a);
                if ((a == fatorsum(b))&&b<10000 &&a!=b)
                {
                    sum += a + b;
                  //  System.out.println(a+" "+b);
                    num[b] = false;
                }
                num[a] = false;
            }
        }
        System.out.println(sum);
    }
}

